<?php
global $age;
function fun() {

    $GLOBALS['age'] = 30;
}

fun();
echo $age; //30